package org.xyf.IM.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xyf.grpcService.HelloReply;
import org.xyf.grpcService.HelloRequest;
import org.xyf.grpcService.UserServiceGrpc;

@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @Resource
    private UserServiceGrpc.UserServiceBlockingStub userServiceBlockingStub;

    @GetMapping("/grpcObservationTest")
    public String grpcObservationTest(){

        log.info("开始测试grpc的可观测性问题!");

        HelloRequest request = HelloRequest.newBuilder()
                .setName("xyf")
                .build();
        HelloReply reply = userServiceBlockingStub.sayHello(request);

        return reply.toString();
    }
}
